package com.itcast.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.itcast.R;
import com.itcast.vo.Order;

public class OrderAdapter extends BaseAdapter {
	private Context context;
	private List<Order> orders;

	public OrderAdapter(Context context, List<Order> orders, ListView orderListView) {
		this.context = context;
		this.orders = orders;
	}

	@Override
	public int getCount() {
		return orders.size();
	}

	@Override
	public Object getItem(int position) {
		return orders.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		View view = View.inflate(context, R.layout.my_order_listitem, null);
		Order order = orders.get(position);

		TextView orderid = (TextView) view.findViewById(R.id.orderId_text);
		final TextView price = (TextView) view.findViewById(R.id.orderPrice_text);
		TextView status = (TextView) view.findViewById(R.id.orderState_text);
		TextView time = (TextView) view.findViewById(R.id.orderTime_text);

		orderid.setText(order.getOrderid());
		status.setText(order.getStatus());
		time.setText(order.getTime());
		price.setText(order.getPrice());
		// =================================

		return view;
	}

}
